package com.polylink.${bean.name}.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.polylink.base.Page;
import com.polylink.${bean.name}.bean.${bean.upName};
import com.polylink.${bean.name}.dao.I${bean.upName}Dao;
import com.polylink.${bean.name}.service.I${bean.upName}Service;

/**
 *@author xiliang.xiao
 *@date 2015年3月23日 上午9:03:48
 *
 **/
@Service
public class ${bean.upName}Service implements I${bean.upName}Service{
	@Autowired
	private I${bean.upName}Dao ${bean.name}Dao;

	@Override
	public boolean save(${bean.upName} ${bean.name}) {
		int i = 0;
		if(${bean.name}.getId()!=null){
			i = ${bean.name}Dao.update(${bean.name});
		}else{
			i = ${bean.name}Dao.add(${bean.name});
		}
		if(i>0){
			return true;
		}
		return false;
	}

	@Override
	public Page list(Page p) {
		List<${bean.upName}> list = ${bean.name}Dao.list(p);
		int count = ${bean.name}Dao.count(p);
		p.setRows(list);
		p.setTotal(count);
		return p;
	}

	@Override
	public boolean delete(String id) {
		int i = ${bean.name}Dao.delete(id);
		if(i>0){
			return true;
		}
		return false;
	}

}
